package patrol.mobile.com.mobilepatrol.activity.track;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.listener.OnRecyclerViewItemClickListener;

import java.util.List;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.BaseActivity;
import patrol.mobile.com.mobilepatrol.adapter.RouteAdapter;
import patrol.mobile.com.mobilepatrol.bean.Route;
import patrol.mobile.com.mobilepatrol.manager.RouteManager;
import patrol.mobile.com.mobilepatrol.utils.CommonUtil;

/**
 * Created by apple on 17/11/20.
 */

public class RouteListActivity extends BaseActivity{
    @BindView(R.id.recycler)
    RecyclerView recyclerView;
    private BaseQuickAdapter mAdapter;
    private List<Route> mList;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_init;
    }

    @Override
    public void setListener() {
        mAdapter.setOnItemClickListener(new OnRecyclerViewItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                Intent intent = new Intent();
                intent.putExtra("id",mList.get(position).manageID);
                setResult(2,intent);
                CommonUtil.exitActivityAndBackAnim(RouteListActivity.this,true);
            }
        });
    }

    @Override
    public void initView() {
        super.initView();
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
    @Override
    public void initData() {
        mList = RouteManager.getAllRoutes();
        mAdapter = new RouteAdapter(this, mList);
        recyclerView.setAdapter(mAdapter);
    }
    @Override
    public void initTitle() {
        iv_back.setImageResource(R.mipmap.up_white);
        iv_back.setVisibility(View.VISIBLE);
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CommonUtil.exitActivityAndBackAnim(RouteListActivity.this, true);
            }
        });
        tv_center_title.setVisibility(View.VISIBLE);
        tv_center_title.setText("选择路线");
    }
}
